<template>
  <div class="iframe">
    <iframe
      :src="url"
      width="100%"
      height="100%"
      allow-scripts
      frameborder="0"
    ></iframe>
  </div>
</template>

<script>
import { getToken } from 'app/global'
import { mapGetters } from 'vuex'
import { getTreeNodeById } from 'utils'
export default {
  name: 'Iframe',
  data() {
    return {
      url: ''
    }
  },
  computed: {
    ...mapGetters(['menus'])
  },
  watch: {
    '$route.path': {
      immediate: true,
      handler() {
        // const serverUrl = 'http://bz.zhuoxiaoyun.com'
        const menu = getTreeNodeById(this.menus, this.$route.path, 'path')
        const token = getToken()
        this.url = menu.url + token.substring(7)
      }
    }
  }
}
</script>

<style lang="scss">
@import 'styles/common.scss';
.iframe {
  width: 100%;
  height: 98%;
}
</style>
